export function getValue(origin: object, keysUrl: string, defaultData: any = []): any {
  const keys = keysUrl.split('.');
  let value = origin as Record<string, any>;
  for (const key of keys) {
    value = value[key] || {};
  }
  return isEmpty(value) ? defaultData : value;
}

export function isEmpty(obj: any) {
  if (obj === null) return true;
  if (obj === undefined) return true;
  if (Object.prototype.toString.call(obj) === '[object Array]' && obj.length === 0) return true;
  if (typeof obj === 'object') return Object.keys(obj).length === 0;
  return false;
}

export function getUid(prefix: string = ''): string {
  return `${prefix}${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
}
